Converted EEPROM library to use nvs instead of partition. #2678
Converted EEPROM library to use nvs instead of partition. #2678me-no-dev merged 6 commits intoespressif:masterfrom lbernstone:EEPROM2nvs
Conversation
…rom partition from all partition table CSV files.
| nvs_commit(_handle); | ||
| nvs_set_blob(_handle, _name, hold_data, size); | ||
| free(hold_data); | ||
| nvs_commit(_handle); |
There was a problem hiding this comment.
this whole block of code needs some comments to explain exactly what is going on :) I got lost with all those reads, writes and erases. What data is where... you need 2 blobs to hold the default 4K EEPROM, but reading through your code I got lost.
There was a problem hiding this comment.
There is no way to expand a key, so in order to do so, it tests for free space, then holds the data while it deletes the key. If it is a new key, it just fills with zeros. I think changing the variable name to key_data will make it clearer.
|
left a few notes :) |
|
|
||
| protected: | ||
| uint32_t _sector; | ||
| nvs_handle _handle; |
There was a problem hiding this comment.
could you maybe forward declare the nvs_handle so it is not required to include nvs in the header?
…the library and persist data
| Serial.println(EEPROM.readByte(address)); | ||
| address += sizeof(byte); | ||
|
|
||
| Serial.println(char(EEPROM.readChar(address))); |
There was a problem hiding this comment.
Does this actually compile? Shouldn't it be println((char)EEPROM.readChar(address));
There was a problem hiding this comment.
travis would have complained :) not sure how Make will like it though
| String sentence = "I love ESP32."; | ||
| EEPROM.writeString(address, sentence); | ||
| Serial.println(EEPROM.readString(address)); | ||
| address += sentence.length(); |
|
This is a good feature that save a bit of flash space but it breaks all deployed systems where factory settings are stored into EEPROM flash partition. |
|
Will do! @lbernstone any ideas on how that can be detected and moved to NVS? |
|
@me-no-dev My reasons: arduino-esp32 is too matured to start having breaking changes caused by memory partitioning. |
|
Hi, in addition to breaking EEPROM it also breaks any files stored earlier in SPIFFS; the SPIFFS offset moved from 0x291000 to 0x290000. On on my system, any SPIFFS files saved with core 1.0.2 cannot be read by core 1.0.3. I can only read SPIFFS with 1.0.3 when i edit my partitions/default.csv back to the 1.0.2 values (line 6: spiffs). Those 1000 bytes gained are not worth breaking backward compatibility in my humble opinion. I was surprised not to find any documentation on this because i assume lots of people have/will run into this problem. |
Converted EEPROM library to use nvs instead of partition.
Removed eeprom partition from all partition table CSV files.